<%--
  Created by IntelliJ IDEA.
  User: tjs
  Date: 2021/8/12
  Time: 15:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<link href="<%=path%>/static/bootstrap4.6.0/css/bootstrap.css" rel="stylesheet">
<script src="<%=path%>/static/jq/jquery-3.6.0.js"></script><!--bootstrap依赖于js所以要先导入-->
<script src="${pageContext.request.contextPath}/static/bootstrap4.6.0/js/bootstrap.bundle.js"></script>
<h4 style="text-align: center">用户找回密码页面</h4>
<div class="container">
    <form action="${pageContext.request.contextPath}/user/forgetPassword" method="get">
        <div class="form-group">
            <label>账户名</label>
            <input type="text" name="userName" id="username" value="${param.name}" class="form-control">
        </div>

        <div class="form-group">
            <label>电话</label>
            <input type="text" name="phone" id="phone" value="${param.price}" class="form-control">
        </div>
        <div class="form-group">
            <label>新密码</label>
            <input type="password" name="password" id="password" value="${param.price}" class="form-control">
        </div>
        <input type="submit" onclick="change()" class="btn btn-success">
    </form>
</div>
<script>
    function change() {
        $.ajax({
            url: "${pageContext.request.contextPath}/user/forgetPassword",
            type: "get",
            data: {
                userName: $("#username").val(),
                phone: $("#phone").val(),
                password: $("#password").val()
            },
            success: function (data) {
                if (data == "ok") {
                    alert("密码找回成功，请重新登录");
                    location.href = "${pageContext.request.contextPath}/login.jsp";

                }
                if (data == "okk") {
                    alert("密码找回错误,你输入的信息有误");
                    location.href = "${pageContext.request.contextPath}/login.jsp";
                }
                if (data == "okkk") {
                    alert("密码找回错误,你输入的信息有误");
                    location.href = "${pageContext.request.contextPath}/login.jsp";
                }

            },
            error: function (data) {


            }
        })


    }
</script>
</body>
</html>
